<?php

namespace App\Kuafu\Activity\Model;

use App\Kuafu\Base\Model\BaseModel;
use App\Kuafu\Base\Model\Traits\KfSoftDeletes;
use App\Kuafu\Product\Model\Product;
use Illuminate\Database\Eloquent\Relations\HasOne;

class ActivityProductMappingModel extends BaseModel
{
    use KfSoftDeletes;


    protected $connection = 'mysql';
    protected $table      = 'activity_product_mappings';
    protected $primaryKey = 'id';


    const TYPE_SUIT = 1;
    const TYPE_GIFT = 2;
    const TYPE_TEXT = [
        self::TYPE_SUIT => "适用菜品",
        self::TYPE_GIFT => "满赠菜品",
    ];

    const GIVE_STOCK_RULE_TYPE_0    = 0;
    const GIVE_STOCK_RULE_TYPE_1    = 1;
    const GIVE_STOCK_RULE_TYPE_TEXT = [
        self::GIVE_STOCK_RULE_TYPE_0 => "无限制",
        self::GIVE_STOCK_RULE_TYPE_1 => "库存限制",
    ];

    /**
     * @return HasOne
     */
    public function productRel(): HasOne
    {
        return $this->hasOne(Product::class, "id", "productId");
    }
}
